//
//  DYRandomizationViewController.m
//  DaYing
//
//  Created by DaYing on 2024/1/13.
//  Copyright © 2024 DaYing. All rights reserved.
//

#import "DYRandomizationViewController.h"

#import "DYLotteryDecisionButtonCell.h"

#import "DYGroupSettingsViewController.h"

@interface DYRandomizationViewController ()

@end

@implementation DYRandomizationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setNavigationItemTitleViewWithTitle:@"随机分组"];

    [self.tableView registerNib:[UINib nibWithNibName:@"DYLotteryDecisionButtonCell" bundle:nil] forCellReuseIdentifier:@"DYLotteryDecisionButtonCell"];
    
    self.tableView.frame = CGRectMake(0,self.navigationBarHeight, kScreenWidth, kScreenHeight - self.navigationBarHeight);
    [self.view bringSubviewToFront:self.navigationBar];
}

#pragma mark - cellDataSource

- (NSArray *)cellDataSource {
    
    if (!self.dataSource) {
        NSMutableArray *arr = [NSMutableArray arrayWithCapacity:4];
        
        __block NSMutableArray *subarr = nil;
        __block NSDictionary *dict = nil;
        
        subarr = [NSMutableArray arrayWithCapacity:1];

        dict =  @{@"class":DYLotteryDecisionButtonCell.class,
                  @"height":@([DYLotteryDecisionButtonCell getCellFrame:[NSNumber numberWithFloat:(kScreenHeight - 200) * 2]]),
                  @"data":[DYLotteryDecisionButtonCellModel ittemModelWithTitle:@"新建分组"],
                  @"delegate":@YES};
        [subarr addObject:dict];
        
        [arr addObject:subarr];

        self.dataSource = arr;
    }
    return self.dataSource;
}

#pragma mark - QBlotteryDecisionButtonCellDelegate 新建分组

- (void)lotteryDecisionButtonCell:(DYLotteryDecisionButtonCell *)cell button:(UIButton *)sender {
    [self gotoGroupSettingsViewController];
}

#pragma mark - goto

//新建分组
- (void)gotoGroupSettingsViewController {
    DYGroupSettingsViewController *vc = [DYGroupSettingsViewController new];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

@end
